
game:setAmbient(0.9,0.9,0.9)

game:addResultMapEntry("score","body","score")

game:bindKey("START_KEY","POINTER_UP")

game:createTargetControlLogic("DoNothingControlLogic",{maxForce=0, maxTorque=0},function(_)
end)

game:createActorDesc({name="SimpleBox"},function(_)
	game:BoxShape(_,{position={x=0.0,y=0.0,z=0.0},rotation={x=0.0,y=0.0,z=0.0},dimension={x=3.0,y=3.0,z=3.0}})
end)

game:createActorDesc({name="Sword"},function(_)
	game:BoxShape(_,{position={x=0.0,y=0.0,z=0.0},rotation={x=0.0,y=0.0,z=0.0},dimension={x=2.5,y=1.0,z=12.0}})
	game:BoxShape(_,{position={x=0.0,y=0.0,z=5.5},rotation={x=0.0,y=0.0,z=0.0},dimension={x=5.0,y=1.5,z=2.0}})
end)

--Hangar
--game:createNode({x=2000.0, y=0.0, z=0.0},{x=0.0, y=180.0, z=0.0},{x=1, y=1, z=1},function(node,controlnode)
--		game:PhysicsEntity("Hangar",node,controlnode,{mesh="Hangar.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
--			game:ParticleSystemBody(_,node,{name="hangar_fireworks", script="bumm"},function(body)end)
--		end)
--		
--end)



-- Map, the base points of the curve path
Map = {
	numberOfPoints = 8,
	point1={x=2200,y=0,z=0},
	point2={x=2500,y=0,z=0},
	point3={x=3000,y=0,z=500},
	point4={x=4500,y=1000,z=1000},
	point5={x=3600,y=800,z=400},
	point6={x=2000,y=0,z=-500},
	point7={x=1000,y=0,z=0},
	point8={x=2200,y=0,z=0}
}

AsteroidMap = {
	numberOfPoints = 6,
	point1={x=2500,y=0,z=0},
	point2={x=3000,y=0,z=500},
	point3={x=4500,y=1000,z=1000},
	point4={x=3600,y=800,z=400},
	point5={x=2000,y=0,z=-500},
	point6={x=1000,y=0,z=0}
}


-- BodyRailControlLogic
game:createBodyRailControlLogic("BodyRailControlLogic", {mapBasePoints = Map, resolution = 0.006} )

-- Map element types
MapElements = {
	BaseElements = {
		numBases = 4,
		element1 = {mesh="Meteor1.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element2 = {mesh="Meteor2.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element3 = {mesh="Meteor3.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element4 = {mesh="Meteor4.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"}
	},
	SpecElements = {
		numSpecs = 4,
		element1 = {mesh="MetalTriangleGrid_small.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element2 = {mesh="OrangeRocket.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element3 = {mesh="Parabola.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
		element4 = {mesh="Satelit.mesh", controlLogic="DoNothingControlLogic",collisionGroup=6, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=false, actorDesc="_boundingBox"},
},
	func = function(_) end
}



-- Generate the Map objects around the map base points
game:createMap("purple_nebula_skybox", {mapBasePoints = Map, resolution = 0.2, percent = 70.0, elementTypes = MapElements, maxElements = 15})

game:createNode({x=2000.0, y=0.0, z=0.0},{x=0.0, y=0.0, z=0.0},{x=1.0, y=1.0, z=1.0},function(node,controlnode)
	game:Entity("fireworks",node,controlnode,{controlLogic="DoNothingControlLogic"},function(entity)
		game:ParticleSystemBody(entity,node,{name="hangar_fireworks", script="bumm"},function(body)
			game:setMasterBody(entity,body)
		end)
	end)
end)

game:createNode({x=0.0, y=0.0, z=-100.0},{x=0.0, y=0.0, z=0.0},{x=1.0, y=1.0, z=1.0},function(node,controlnode)
	game:Entity("body",node,controlnode,{controlLogic="BodyRailControlLogic"},function(entity)
		game:NodeBody(entity,node,{name="bodyNode"},function(body)
				game:setMasterBody(entity,body)
		end)
		game:setEntityStatus(entity,"WAITING")
	end)

	game:createCamera(node,{name="mainCam"})
	game:addNode(node,controlnode,{x=2200.0, y=-10.0, z=100.0},{x=0.0, y=0.0, z=0.0},{x=2.0, y=2.0, z=2.0},function(node,controlnode)
		game:Entity("kard",node,controlnode,{controlLogic="PlayerControlLogic"},function(entity)
			game:PhysicsBody(entity,node, {collisionGroup=1, weight=300.0, boundingBox=3.95, isStatic=false, isKinematic=true,disableGravity=true, actorDesc="Sword"},function(body)end) 
			game:OgreBody(entity,node, {mesh="ZealotInfected.mesh"}, function(body)
				game:setMasterBody(entity,body)
			end)
			game:ParticleSystemBody(entity,node,{name="bodyNodePartcile", script="space_smoke"},function(body)end)
			game:setEntityStatus(entity,"WAITING")
			game:addHUD(entity)
			game:addTrigger(entity,function(_)
				game:ExplodeAction(_)
				game:KilledReq(_)
				game:PSysAction(_,{script="space_explode"})
				game:GameOverAction(_)
				game:KillAction(_,"body")
				game:CustomScriptAction(_,function()
					game:playAudioFromFile("media/audio/sound/Explosion2.wav", false, 1.0, {x=0.0, y=0.0, z=0.0})
					--game:createAudioWithName("alarm", "media/audio/sound/alarm.wav", true, 1.0, {x=0.0, y=0.0, z=0.0})
					--game:playAudioByName("alarm")
					game:setWindowVisible("GameOverWindow",true)
					game:setCursorVisible(true)
				end)
			end)
			--game:addTrigger(entity,function(_)
				--game:PositionReq(_,{x=14500,y=500,z=200 ,radius=100})
				--game:GameOverAction(_)
			--end)
			--game:addTrigger(entity,function(_)
				--game:NegateReq(_,function(dummy)
					--game:FreeRayReq(dummy,{position={x=0,y=5,z=0},direction={x=0,y=0,z=1},distance=1})
				--end)
				--game:KillAction(_,"body")
				--game:DamageAction(_,{damage=5000})
				--game:GameOverAction(_)
			--end)
			--game:addTrigger(entity,function(_)
				--game:NegateReq(_,function(dummy)
					--game:FreeRayReq(dummy,{position={x=0,y=5,z=0},direction={x=0,y=0,z=-1},distance=1})
				--end)
				--game:KillAction(_,"body")
				--game:DamageAction(_,{damage=5000})
				--game:GameOverAction(_)
			--end)

		end)
	end)
end)


game:createNode({x=50000.0, y=1000.0, z=1000.0},{x=0.0, y=0.0, z=0.0},{x=400, y=400, z=400},function(node,controlnode)
		game:PhysicsEntity("PlanetOceanic02",node,controlnode,{mesh="PlanetOceanic02.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
			
		end)
end)


game:setRoundCamera({position={x=0.0, y=0.0, z=0.0}, height=1000, radius=50, target="kard"})



